<template>
  <div>
     <div class="config">
        <div class="back" onclick="window.history.go(-1)"><img src="../assets/images/back.png" alt=""></div>
        <p>我的钱包</p>
    </div>
    <div class="header">
        <p class="title">我的余额(元)</p>
        <p class="money">{{data.total}}</p>
         <router-link to="/applyCash">
            <span>申请提现</span>
          </router-link>
        
    </div>
      <div class="box"> 
        <div class="row">             
            <p>招商收益(元): {{data.business}}</p>
        </div> 
         <div class="row">             
            <p>消费收益(元): {{data.cost}}</p>
        </div> 


          
  
     </div>
 


  </div>
</template>

<script>
export default {
    name: "myWallet",
    data() {
        return {
            data: {}
        };
    },
    beforeCreate() {
        document.getElementsByTagName("body")[0].style.background = "#ececec";
    },
    methods: {
        applyCash() {
            var qs = require("qs");

            this.axios({
                method: "post",
                url: `${this.siteUrl}/setCashed`,
                data: qs.stringify({
                    uid: localStorage.getItem("uid"),
                    price:this.data.total
                })
            })
                .then(response => {
                  
                    if ((response.data.result == 200)) {
                        this.$Message.success("正在申请提现")                  
                    } else {
                        alert("请求失败");
                    }
                })
                .catch(function(error) {
                    console.log(error);
                });
        }
    },
    mounted() {
        var qs = require("qs");

        this.axios({
            method: "post",
            url: `${this.siteUrl}/getWallet`,
            data: qs.stringify({
                uid: localStorage.getItem("uid")
            })
        })
            .then(response => {
               
                if ((response.data.result == 200)) {
                    this.data = response.data.data;
                } else {
                    alert("请求失败");
                }
            })
            .catch(function(error) {
                console.log(error);
            });
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.header {
    height: 200px;
    background: #5aa0c8;
    position: relative;
    color: #fff;
    /* z-index:-1; */
}
.header .title {
    position: absolute;
    left: 20px;
    top: 40px;
}
.header .money {
    position: absolute;
    left: 20px;
    top: 70px;
    font-size: 40px;
}
.header span {
    position: absolute;
    right: 20px;
    top: 90px;
    box-shadow: 0px 0px 1px 1px #f7f7f7;
    padding: 3px 8px;
    border-radius: 2px;
    color: #fff;
    font-size: 12px;
}
.box {
    width: 94%;
    margin-left: 3%;
    border-radius: 3px;
    background: #fff;
    margin-top: -40px;
    overflow: hidden;
    padding-bottom: 20px;
    z-index: 2;
    position: absolute;
}

.row {
    height: 50px;
    line-height: 50px;
    background: #fff;
    border-bottom: 1px solid #f2f2f2;
    margin: 8px;
    font-size: 14px;
}
</style>
